<?

include_once ("Server.php");
include_once ("config.php");

function getDraft($draftID)
{
	$con = connect();
	$query = "SELECT id,name,teams,current_round,current_pick FROM draft ";
	$query = $query . "WHERE id = " . $draftID;
	$draftRows = query($query, $con);
	if (mysql_num_rows($draftRows) > 0)
	{
		$draftRow =  mysql_fetch_array($draftRows);
		$draft = new Draft($draftRow['id'], $draftRow['name'], $draftRow['teams']);
		$draft->currentRound = $draftRow['current_round'];
		$draft->currentPick = $draftRow['current_pick'];

	}
	
	disconnect($con);
	return $draft;
}

function incrementDraft($draft)
{
	if ($draft->increment())
	{
		$con = connect();
		$q = "UPDATE draft SET current_pick='".$draft->currentPick."', current_round='".$draft->currentRound."'";
		$q= $q . "WHERE id=".$draft->id;
		query($q,$con);
		disconnect($con);
		return true;
	}
	else
	{
		finalizeDraft();
	}
}

function finalizeDraft()
{
	echo "DraFT iS dONE yO";
	return false;
}
?>